<div class="playoff">
<h2><?php echo __('Playoff', true).': '.$championship['Championship']['strName']; ?></h2>
<table>
<?php
$finalDay = $days-2;
$final2Day = $days-1;
$otherDays = $days-3;

$colspan = $nbTeams/2;
$nbMatch = 1;

/* The final */
echo '<tr><th colspan="'.$colspan.'">';
$calendar = $calendars[$finalDay];
if($calendar) {
	echo $html->link($calendar[0]['TeamHome']['strName'], array('controller' => 'teams', 'action' => 'view', $calendar[0]['TeamHome']['ID']));
	echo ' '.$calendar[0]['Calendar']['Home_iScore'].' - '.$calendar[0]['Calendar']['Away_iScore'].' ';
	echo $html->link($calendar[0]['TeamAway']['strName'], array('controller' => 'teams', 'action' => 'view', $calendar[0]['TeamAway']['ID']));
} else {
	echo 'Winners of the Semi Final';
}
echo '</th></tr>';

for ( $day = $otherDays; $day > 0; $day-- ) {
	$colspan = $colspan / 2;
	$nbMatch = $nbMatch * 2;
	echo '<tr>';
	if($calendars[$day]) {
		foreach ( $calendars[$day] as $calendar ) {
			echo '<td colspan="'.$colspan.'">';
				echo $html->link($calendar['TeamHome']['strName'], array('controller' => 'teams', 'action' => 'view', $calendar['TeamHome']['ID']));
				echo ' '.$calendar['Calendar']['Home_iScore'].' - '.$calendar['Calendar']['Away_iScore'].' ';
				echo $html->link($calendar['TeamAway']['strName'], array('controller' => 'teams', 'action' => 'view', $calendar['TeamAway']['ID']));
			echo '</td>';
		}
	} else {
		$previous = $day-1;
		for($i = 0; $i < $nbMatch; $i++) {
			echo '<td colspan="'.$colspan.'">Winners of Day #'.$previous.'</td>';
		}
	}
	echo '</tr>';
}
?>
</table>
</div>